<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

        // 数组的长度和值都可以被任意改变
        //    直接通过下标赋值
        //    改变length的值





        // var a = 1 ;
        // a-- ;


        // var b = 'hi' ;
        // b += ' hello' ;


        var arr = [] ;
        console.log(arr.length) ;   // 0

        arr[0] = 1 ;
        console.log(arr) ;
        console.log(arr.length) ;  // 1


        arr[100] = 5 ;
        console.log(arr) ;
        console.log(arr.length) ;

        console.log(arr[2]) ;  // undefined


        arr[0] = 'hello' ;
        console.log(arr) ;


        arr.length = 2 ;
        console.log(arr) ;

    </script>
    
</body>
</html>